package com.sunricher.telinkblemeshlib.models;

import android.util.Range;

import java.util.ArrayList;

public class DynamicControl {

    private int index = 1;

    public int getIndex() {
        return index;
    }

    /**
     * @param index range [1, 16], default is 1.
     */
    public void setIndex(int index) {
        this.index = index;
    }

    private Range<Integer> indexRange = new Range<>(1, 16);

    public Range<Integer> getIndexRange() {
        return indexRange;
    }

    private ArrayList<Item> items = new ArrayList<>();

    public void setIndexRange(Range<Integer> indexRange) {
        this.indexRange = indexRange;
    }

    public ArrayList<Item> getItems() {
        return items;
    }

    public void setItems(ArrayList<Item> items) {
        this.items = items;
    }

    public static class Item {
        private int hour = 0;
        private int minute = 0;
        private int delay = 0;
        private int brightness = 0;
        private int red = 0;
        private int green = 0;
        private int blue = 0;
        private int whiteOrCt = 0;
        private boolean whiteOrCtEnabled = true;

        public int getHour() {
            return hour;
        }

        public void setHour(int hour) {
            this.hour = hour;
        }

        public int getMinute() {
            return minute;
        }

        public void setMinute(int minute) {
            this.minute = minute;
        }

        public int getDelay() {
            return delay;
        }

        public void setDelay(int delay) {
            this.delay = delay;
        }

        public int getBrightness() {
            return brightness;
        }

        public void setBrightness(int brightness) {
            this.brightness = brightness;
        }

        public int getRed() {
            return red;
        }

        public void setRed(int red) {
            this.red = red;
        }

        public int getGreen() {
            return green;
        }

        public void setGreen(int green) {
            this.green = green;
        }

        public int getBlue() {
            return blue;
        }

        public void setBlue(int blue) {
            this.blue = blue;
        }

        public int getWhiteOrCt() {
            return whiteOrCt;
        }

        public void setWhiteOrCt(int whiteOrCt) {
            this.whiteOrCt = whiteOrCt;
        }

        public boolean isWhiteOrCtEnabled() {
            return whiteOrCtEnabled;
        }

        public void setWhiteOrCtEnabled(boolean whiteOrCtEnabled) {
            this.whiteOrCtEnabled = whiteOrCtEnabled;
        }
    }

    public boolean isValid() {
        return indexRange.contains(index);
    }

    private final Range<Integer> timeRange = new Range<Integer>(1, 8);

    public boolean isTime() {
        return timeRange.contains(index);
    }

    public boolean isDelay() {
        return !isTime();
    }
}
